<?php
namespace app\api\controller;

use app\admin\model\Article;
use app\common\controller\Api;

class News extends Api
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';

    // 新闻列表
    public function index()
    {
        $page_size=input('page_size',10);
        $cateId=input('category_id',17);
        $list = Article::where('category_id',$cateId )->order('weigh desc,id desc')->paginate($page_size);
        $this->success('ok', $list);
    }
    // 新闻详情
    public function detail()
    {
        $id=input('a',0);
        $detail=Article::get($id);
        if(!$detail) $this->error('文章不存在');
        $this->success('ok', $detail);
    }
}